package com.codeczx.myretrofitdemo.retrofit;

import okhttp3.ResponseBody;

/**
 * Created by codeczx on 2018/3/26.
 */

public class Response<T> {

    public static <T> Response<T> error(ResponseBody bufferBody, okhttp3.Response rawResponse) {
        return new Response<>(rawResponse,null,bufferBody);
    }

    static <T> Response<T> success(T body,okhttp3.Response rawResponse){
        return new Response<>(rawResponse,body,null);
    }

    private final  okhttp3.Response rawResponse;
    private final T body;
    private final ResponseBody errorBody;

    private Response(okhttp3.Response rawResponse, T body,ResponseBody errorBody){
        this.rawResponse = rawResponse;
        this.body = body;
        this.errorBody = errorBody;
    }

    public T body(){
        return body;
    }

}
